package f;

import f.f0.c;
import g.e;
import g.f;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;

/* compiled from: FormBody */
public final class o extends z {
    public static final t c = t.a("application/x-www-form-urlencoded");
    public final List<String> a;
    public final List<String> b;

    /* compiled from: FormBody */
    public static final class a {
        public final List<String> a = new ArrayList();
        public final List<String> b = new ArrayList();

        public a a(String str, String str2) {
            Objects.requireNonNull(str, "name == null");
            Objects.requireNonNull(str2, "value == null");
            this.a.add(r.c(str, " \"':;<=>@[]^`{}|/\\?#&!$(),~", true, false, true, true, null));
            this.b.add(r.c(str2, " \"':;<=>@[]^`{}|/\\?#&!$(),~", true, false, true, true, null));
            return this;
        }
    }

    public o(List<String> list, List<String> list2) {
        this.a = c.p(list);
        this.b = c.p(list2);
    }

    public final long a(@Nullable f fVar, boolean z) {
        e eVar;
        if (z) {
            eVar = new e();
        } else {
            eVar = fVar.A();
        }
        int size = this.a.size();
        for (int i = 0; i < size; i++) {
            if (i > 0) {
                eVar.B0(38);
            }
            eVar.G0((String) this.a.get(i));
            eVar.B0(61);
            eVar.G0((String) this.b.get(i));
        }
        if (!z) {
            return 0;
        }
        long j = eVar.b;
        eVar.n();
        return j;
    }

    public long contentLength() {
        return a(null, true);
    }

    public t contentType() {
        return c;
    }

    public void writeTo(f fVar) throws IOException {
        a(fVar, false);
    }
}
